package com.jstyle.jclife.adapter;

import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.ViewGroup;

import com.jstyle.jclife.fragment.EcgShowFragment;
import com.jstyle.jclife.fragment.ShareFirstFragment;
import com.jstyle.jclife.fragment.ShareLongPictureFragment;
import com.jstyle.jclife.fragment.SharePictureFragment;
import com.jstyle.jclife.model.HealthData;

import java.util.ArrayList;
import java.util.List;

import retrofit2.http.PUT;


/**
 * 历史数据适配器
 * @author Administrator
 *
 */
public class SharePreviewViewPagerAdapter extends FragmentStatePagerAdapter {
	int size=3;
	List<HealthData>pathList=new ArrayList<>();
	String path;
	String date;
	String fastPace;
	String lowPace;
	public SharePreviewViewPagerAdapter(FragmentManager fm
			,String path,String date) {
		super(fm);
		this.path=path;
		this.date=date;
		// TODO Auto-generated constructor stub
	}

	private static final String TAG = "MyViewPagerAdapter";
	Fragment currentFragment;
	@Override
	public Fragment getItem(int arg0) {
		// TODO Auto-generated method stub
		int mSize=3-size+arg0;
		switch (mSize){
			case 0:
				return ShareFirstFragment.newInstance(path,date,fastPace,lowPace);
			case 1:
				return ShareLongPictureFragment.newInstance(path,"");
			case 2:
				return SharePictureFragment.newInstance(path,date);
		}
		return ShareLongPictureFragment.newInstance(path,"");
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return size;
	}
	public void setSize(int size){
		this.size=size;
	}
	public void setPace(String fastPace,String lowPace){
		this.fastPace=fastPace;
		this.lowPace=lowPace;
	}

//	public void changeSize(int size, List<String>pathList){
//		this.size=size;
//		this.pathList=pathList;
//		notifyDataSetChanged();
//	}
	@Override
	public int getItemPosition(Object object) {
		// TODO Auto-generated method stub
		return PagerAdapter.POSITION_NONE;
	}

	@Override
	public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
		super.setPrimaryItem(container, position, object);
		currentFragment=(Fragment)object;
	}
	public Fragment getCurrentFragment(){
		return  currentFragment;
	}
}
